package cn.sangedon.review.data.utils;

import java.util.Random;

/**
 * 爬虫工具类
 */
public class SpiderUtil {
    /**
     * 随机睡眠0 ～ 120秒
     */
    public static void randomDelay() throws InterruptedException {
        randomDelay(120);
    }

    /**
     * 随机睡眠
     *
     * @param baseTime 基数时间，单位：秒
     */
    public static void randomDelay(Integer baseTime) throws InterruptedException {
        Long sleepTime = 1000L;
        Random random = new Random();
        sleepTime = random.nextInt(baseTime) * sleepTime;
        Thread.sleep(sleepTime);
    }
}
